<script>
	export default {
		onLaunch: function(options) {
			// 平台不一致时清空token
			// 扫码进入
			if (options.query && options.query.channel) {
				if (uni.getStorageSync('app') !== options.query.channel) {
					uni.removeStorageSync('token');
					uni.removeStorageSync('stepToken');
					uni.removeStorageSync('userId');
				}
				
				uni.setStorageSync('app', options.query.channel);
				this.$service.common.zfbStatistics.add({
					platform: '支支权益',
					channel: options.query.channel || '5gqy',
					noToken: true
				})
			}
			// 小程序跳转进入 接收extraData
			if (options.referrerInfo && options.referrerInfo.extraData && options.referrerInfo.extraData.channel) {
				if (uni.getStorageSync('app') !== options.referrerInfo.extraData.channel) {
					uni.removeStorageSync('token');
					uni.removeStorageSync('stepToken');
					uni.removeStorageSync('userId');
				}
				
				uni.setStorageSync('app', options.referrerInfo.extraData.channel);
				this.$service.common.zfbStatistics.add({
					platform: '支支权益',
					channel: options.referrerInfo.extraData.channel || '5gqy',
					noToken: true
				})
			}
			
			// uni.setStorageSync('app', 'ddyl');
			
			uni.showTabBarRedDot({ index: 1 });
			
			this.$service.common.zfbStatistics.add({
				platform: '支支权益',
				channel: JSON.stringify(options),
				noToken: true
			})
		},
		onShow: function(options) {
			// 小程序跳转进入extraData
			if (options.referrerInfo && options.referrerInfo.extraData && options.referrerInfo.extraData.channel) {
				if (uni.getStorageSync('app') !== options.referrerInfo.extraData.channel) {
					uni.removeStorageSync('token');
					uni.removeStorageSync('stepToken');
					uni.removeStorageSync('userId');
				}
				
				uni.setStorageSync('app', options.referrerInfo.extraData.channel);
			}
			console.log('App Show')
		},
		onHide: function() {
			console.log('App Hide')
		}
	}
</script>

<style lang="scss">
	/*每个页面公共css */
    @import './static/scss/index.scss';
	page {
		background: #EFF0F1;
	}
</style>
